from Products.Five import zcml
from Products.Five import fiveconfigure

from Testing import ZopeTestCase as ztc

from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import onsetup, PloneSite

@onsetup
def setup_itx_bookscatalog():
    """Set additional products required for the Itx BooksCatalog Content
    """
    
    # Load the ZCML configuration for the itx.policy package.
    
    fiveconfigure.debug_mode = True
    import itx.bookscatalog
    zcml.load_config('configure.zcml', itx.bookscatalog)
    fiveconfigure.debug_mode = False
    
    # We need to tell the testing framework that these products
    # should be available. This can't happen until after we have loaded
    # the ZCML.
    
    ztc.installPackage('itx.bookscatalog')	
    
# The order here is important: We first call the (deferred) function which
# installs the products we need for the itx package. Then, we let 
# PloneTestCase set up this product on installation.

setup_itx_bookscatalog()
ptc.setupPloneSite(products=['itx.bookscatalog',])

class BooksCatalogTestCase(ptc.PloneTestCase):
    """Base class used for test cases
    """
class BooksCatalogFunctionalTestCase(ptc.FunctionalTestCase)
    """Test case class used for functional (doc-)tests
    """
